package khtn.mylocation;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.widget.TabHost;


public class MyLocationActivity extends TabActivity  {
   
	private TabHost tabHost = null;  // The activity TabHost
	private int indexTab = 0;
	
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.main);
	    if(getIntent() != null && getIntent().getExtras() != null) {
	    	indexTab = getIntent().getExtras().getInt("setIndexTab", 0);
	    }
	    tabHost = getTabHost();  // The activity TabHost
	    TabHost.TabSpec spec;  // Resusable TabSpec for each tab
	    Intent intent;  // Reusable Intent for each tab
	    Resources res = getResources();
	    
	    // Create an Intent to launch an Activity for the tab (to be reused)
	    intent = new Intent().setClass(this, GoogleMapActivity.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("maps").setIndicator("Maps", res.getDrawable(R.drawable.google_maps_icon)).setContent(intent);
	    tabHost.addTab(spec);
	    
	    intent = new Intent().setClass(this, CategoriesActivity.class);

	    // Initialize a TabSpec for each tab and add it to the TabHost
	    spec = tabHost.newTabSpec("categories").setIndicator("Categories", res.getDrawable(R.drawable.list)).setContent(intent);
	    tabHost.addTab(spec);
	
	    Log.i("index", String.valueOf(indexTab));
	    this.setTab(indexTab);
	}
	
	public void setTab(int index) {
		tabHost.setCurrentTab(index);
	}
}